Welcome to JavaScript!

6.18 构造函数初识

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Title</title>

<script type="text/javascript">

function ren(){

this.name=""; //this:表示现在还不知道,没有具体的名称;

this.sex="男";

this.age=40;

this.height=169

}

var laoliu=new ren(); //通过new方法来创建具体的叫"laoliu"的人

console.log(laoliu);

</script>

</head>

<body>

</body>

</html>